package programmercarl.动态规划.C8;

class Solution1 {
    public int integerBreak(int n) {
        //dp[i] 为正整数 i 拆分后的结果的最大乘积
        int[] dp = new int[n + 1];
        dp[2] = 1;
        for (int i = 0; i <= n; i++) {
            for (int j = 1; j < i; j++) {// 拆分j=0无意义
                dp[i] = Math.max(dp[i], Math.max(j * (i - j), j * dp[i - j]));
            }
        }
        return dp[n];
    }
}
